<template>
  <div class="PersonIndexActiveAction tPage">
    <ul>
      <li v-for="(v,km) in dataList">
        <div class="flex">
          <div class="flex-item" style="flex: 1">
            <div class="midfont" style="font-weight: bold">{{km}}</div>
          </div>
          <div class="flex-item" style="flex: 4;padding-left: .3rem">
            <template v-for="vv in v">
              <!--作品-->
              <div v-if="action_type.Works.indexOf(vv.action_type)>-1" class="block">
                <div class="minifont action_info">{{vv.action_info}}</div>
                <div class="flex" style="flex-wrap: wrap;justify-content: left">
                  <div class="flex-item img" v-for="vvv in vv.action_detail">
                    <ImageBlock  @click.native="gotoUrl(domain+'/MinProgram2/Work/detail_o?work_id='+vvv.works_id)" :img-src="domain+'/Uploads'+vvv.s_path" width="1rem" height="1rem"></ImageBlock>
                  </div>
                </div>
              </div>

              <!--文章-->
              <div v-if="action_type.Articles.indexOf(vv.action_type)>-1" class="block">
                <div class="minifont action_info">{{vv.action_info}}</div>
                <div class="flex" style="flex-wrap: wrap;justify-content: left">
                  <div class="flex-item img" v-for="vvv in vv.action_detail">
                    <ImageBlock  @click.native="gotoUrl(domain+'/MinProgram2/Article/detail_o?article_id='+vvv.article_id)"  :img-src="domain+'/Uploads'+vvv.article_cover" width="1rem" height="1rem"></ImageBlock>
                  </div>
                </div>
              </div>

              <!--展讯-->
              <div v-if="action_type.SpreadTRums.indexOf(vv.action_type)>-1" class="block">
                <div class="minifont action_info">{{vv.action_info}}</div>
                <div class="flex" style="flex-wrap: wrap;justify-content: left">
                  <div class="flex-item img" v-for="vvv in vv.action_detail">
                    <ImageBlock @click.native="gotoUrl(domain+'/MinProgram2/Spreadtrum/detail?spreadtrum_id='+vvv.id)" :img-src="domain+'/Uploads'+vvv.s_path" width="1rem" height="1rem"></ImageBlock>
                  </div>
                </div>
              </div>
            </template>
          </div>
        </div>
      </li>
    </ul>
    <GetMore @getmore="get_dataList" ref="GetMore" :getDataListDoing="getDataListDoing"></GetMore>
  </div>
</template>
<style scoped>
.img{max-width: 1rem;margin: .1rem}
.action_info{text-align: left}
.block{margin-top: .3rem}
</style>
<script>
import ImageBlock from "../../components/images/ImageBlock";
import GetMore from "../../components/buttons/GetMore";
export default {
  name:"ActiveAction",
  components:{ImageBlock,GetMore},
  data(){
    return {
      action_type:{
        'Works':["1","2","5"],
        'Articles':["3","4","6"],
        'SpreadTRums':["7","8"]
      },
      dataList:[],
      page:1,
      dUserinfo:[],
      getDataListDoing:0
    }
  },
  methods:{
    get_dataList(){
      let _this = this
      if (!_this.dUserinfo.uid)return false;
      if (_this.getDataListDoing)return false;
      _this.getDataListDoing=1
      myjs.UserActionsGetDataList({page:_this.page,uid:_this.dUserinfo.uid},function(data){
        _this.dataList = {..._this.dataList,...data.data}
        console.log(_this.dataList);
        _this.page++
        _this.getDataListDoing=0
      },function(){
        _this.$refs.GetMore.setNoMore()
        _this.getDataListDoing=0
      })
    }
  },
  created() {
    let _this=this
    _this.$nextTick(function(){
      $(window).scroll(function(){
        if (_this.$route.name!==_this.$options.name)return false
        let scrollTop = $(this).scrollTop();
        let scrollHeight = $(document).height();
        let windowHeight = $(this).height();
        if(scrollHeight - (scrollTop + windowHeight) < 100){
          console.log("you are in the bottom"+_this.$options.name);
          _this.get_dataList()
        }
      })
    })
  },
  mounted() {
    let _this=this
    setTimeout(function(){
      _this.dUserinfo = _this.$store.getters.getUserinfo
      if (!_this.dUserinfo){
        _this.$router.push({name:"PersonIndex"})
      }
      _this.get_dataList()
    },500)
  }
}
</script>
